Skip to main content

All Questions

0votes
2answers
730views

Should I instantiate the state objects of a finite state machine?

I have a class hierarchy with a base State class, several inheriting classes each named after their relevant state, and an FSM class that contains all the states in a particular state machine as well ...
ewhiting's user avatar
3votes
5answers
371views

Add specific behavior inside classes

I'm learning to make games with OOP and there's something I don't understand. What I can see is that the more I add methods to a class, the less it becomes reusable and flexible. For example, if we ...
Voko's user avatar
  • 233
1vote
1answer
180views

Building a MVC Framework: Should I get an instance of Database, or should I extend with a "general" model class that already has an instance of DB

I am trying to get a database instance via any model-class that uses the database. This is ideal in my opinion: class UserAuthenticator { private $db; private $customer; public ...
Kar19's user avatar
3votes
3answers
392views

How to store objects with inconsistant properties

I have real-world materials that are defined by various properties, some common, some not, that I would like to map to objects in C#. For example, Concrete has properties A, B, C, and Metal has ...
gazoh's user avatar
2votes
1answer
444views

Mediator pattern or facade or ...?

I'm writing an app which tracks device location and based on some factors (user gets an assignment), it needs to change the location tracking settings (for example, frequency). I have an issue with ...
Daniel's user avatar
3votes
2answers
185views

When to use a repository/service vs an instance variable?

When does an object truly belong to a class? I'm familiar with the "has-a" relationship, but in the case of an Employee object, it "has-a" 401k, but it's not really composed of a 401k object. As an ...
keelerjr12's user avatar
11votes
2answers
12kviews

Design patterns for creating objects that have a list of objects that also have a list of objects

In terms of good OOP design, what is the best way to structure code that is just containers of list of objects that contains other lists of objects that also are just other containers? Example: A ...
WP0987's user avatar
14votes
4answers
2kviews

How specific should the Single Responsibility pattern be for classes?

For example, suppose you have a console game program, which has all kinds of input/output methods to and from the console. Would it be smart to keep them all in a single inputOutput class or break ...
shinzou's user avatar
-1votes
2answers
229views

Per my design requirements, does this design hierarchy seem reasonable?

Background Construction Note that I am using C# here, but it may not be necessary to provide input to my conceptual questions about design. Consider the following design methodology... I work at a ...
Snoop's user avatar
  • 2,748
1vote
3answers
2kviews

How To Extend Parent Methods in Children Classes?

There is a parent class with a method which many children use but many children extend the method, what is the best way to extend it without violating DRY? Here are my 2 current solutions: 1: The ...
Will Beauchamp's user avatar
1vote
2answers
848views

How should I structure these Python classes?

Base Class I have a class called Remote. This class represents a remote machine and has properties such as ip, hostname, username, and password, as well as methods for transferring files to/from the ...
ArtOfWarfare's user avatar
0votes
4answers
722views

Fixing class Hierarchy design mistakes due to incorrect inheritance

I have a code like this. My derived class man, may not properly have a member function declared pure virtual higher up the hierarchy. eg. WagTail here class mammal{ public: virtual void WagTail() ...
The Vivandiere's user avatar
1vote
3answers
204views

where should put showSchedule method in school system

In my school management system I have this partial class diagram: 1- In one use case student want to see his schedule of classes in week. this is what i suppose to do: get student object from ...
mohsenJsh's user avatar
3votes
2answers
2kviews

many to many relation in database schema and oop class diagram

I have Student and Group entities. Student can have many groups and Group can have many students too. so in database I should have middle class and change many-to-many relation to one-to-many and many-...
mohsenJsh's user avatar
6votes
4answers
5kviews

When should something be a class? And are my chosen classes good OO design?

My background: I am new to programming. Python is my only programming knowledge. I program as a hobby, and I'm teaching myself by reading copious amounts of books. I understand enough about OOP to ...
BBedit's user avatar

153050per page
close